package example.org;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;
import android.widget.Toast;

public class ScreenShotService extends Service {
	private Thread task;

	@Override
	public IBinder onBind(Intent intent) {
		return null;
	}

	@Override
	public void onCreate() {
		super.onCreate();
		Toast.makeText(this, "My Service Created", Toast.LENGTH_SHORT).show();
		task = new Thread(new Runnable() {

			@Override
			public void run() {
				while (true) {
					try {
						Thread.sleep(100);
						// if
						// (intent.getAction().equals(Intent.ACTION_SCREEN_OFF))
						// {
						// Log.d("Screen Off", "true");
						// }
					} catch (Exception e) {
						Log.d("Error : ", e.getMessage());
					}
				}
			}
		});
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
		Toast.makeText(this, "My Service Stopped", Toast.LENGTH_SHORT).show();
		task.interrupt();
	}

	@Override
	public void onStart(Intent intent, int startId) {
		super.onStart(intent, startId);
		
	}
}
